/*
  Copyright © 2014 Allen County Public Library.

  ACPL Mobile is free software: This program is distributed and you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.  ACPL Mobile is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, including without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with ACPL Mobile. If not, see http://www.gnu.org/licenses/.
 * 
 * 
 * Description: This class extends Application, and provides global fields and methods accessible throughout 
 * 				the application. 
 */

package us.in.lib.acpl.Mobile_ACPL.context;


import us.in.lib.acpl.Mobile_ACPL.service.OnBootReceiver;
import us.in.lib.acpl.Mobile_ACPL.service.account.AccountOnAlarmReceiver;
import us.in.lib.acpl.Mobile_ACPL.ws.BestSellerSearchHandler;
import us.in.lib.acpl.Mobile_ACPL.ws.MainSearchHandler;
import us.in.lib.acpl.Mobile_ACPL.ws.MoreAuthorSearchHandler;
import android.app.Application;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;

public class Mobile_ACPL extends Application {
    //ACPL: Removed Sirsi Web Services URL
	public static final String WS_HOST="";
	public static final String LOG_TAG = "ACPL Mobile";
	String searchLibraryFilter;
	String searchTypeFilter;
	private MainSearchHandler mainSearchHandler;
	private MoreAuthorSearchHandler authorSearchHandler;
	private BestSellerSearchHandler bestSellerSearchHandler;

	
	public BestSellerSearchHandler getBestSellerSearchHandler() {
		return bestSellerSearchHandler;
	}


	public void setBestSellerSearchHandler(
			BestSellerSearchHandler bestSellerSearchHandler) {
		this.bestSellerSearchHandler = bestSellerSearchHandler;
	}


	@Override
	public void onCreate() {
		try {
			Class.forName("android.os.AsyncTask");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}

		SharedPreferences prefs = this.getSharedPreferences("myPrefs",
				Context.MODE_WORLD_WRITEABLE);

		boolean alarmUp = (PendingIntent.getBroadcast(this
				.getApplicationContext(), 0,
				new Intent(this.getApplicationContext(),
						AccountOnAlarmReceiver.class),
				PendingIntent.FLAG_NO_CREATE) != null);

		if (!alarmUp) {
			Intent intent = new Intent(this, OnBootReceiver.class);
			this.sendBroadcast(intent);
		}

		

	}


	public MainSearchHandler getSearchHandler() {
		return mainSearchHandler;
	}

	public void setSearchHandler(MainSearchHandler searchHandler) {
		this.mainSearchHandler = searchHandler;
	}

	public MoreAuthorSearchHandler getAuthorSearchHandler() {
		return authorSearchHandler;
	}

	public void setAuthorSearchHandler(
			MoreAuthorSearchHandler authorSearchHandler) {
		this.authorSearchHandler = authorSearchHandler;
	}

	public void showConnectionError() {

	}
}
